package type_func

import (
	"fmt"

	"github.com/pkg/errors"
)

func TypeTest() {
	var arr [10]int
	arr[0] = 1
	arr[1] = 2
	fmt.Printf("arr: %v\n", arr)
	// arr: [1 2 0 0 0 0 0 0 0 0]

	var refArr []int = []int{1, 2, 3, 4}
	refArr = append(refArr, 5)
	fmt.Printf("refArr: %v\n", refArr)
	// refArr: [1 2 3 4 5]

	var mapTest map[string]string = map[string]string{
		"key1": "value1",
		"key2": "value2",
	}
	mapTest["key2"] = "value2"
	mapTest["key3"] = "value3"

	fmt.Printf("mapTest: %v\n", mapTest)
	// mapTest: map[key1:value1 key2:value2 key3:value3]

	var chanTest chan int = make(chan int, 3)

	chanTest <- 1
	chanTest <- 2
	chanTest <- 3

	fmt.Printf("chanTest: %v\n", chanTest)
	fmt.Println(<-chanTest)
	fmt.Println(<-chanTest)
	fmt.Println(<-chanTest)
	// 1 2 3
}

func ErrorTest() {

	var er = errors.New("is error!")
	fmt.Printf("er: %v\n", er.Error())

	err2 := fmt.Errorf("is second error")

	fmt.Print(err2)
	// er: is error!
	// is second error!

	myError := MyError{
		errors.New("my error"),
	}
	fmt.Printf("myError: %v\n", myError)
	// myError: my error
}

type MyError struct {
	err error
}

func (e MyError) Error() string {
	return e.err.Error()
}

func TestParams(args ...string) {
	fmt.Printf("args: %v\n", args)
}
